package com.jboom.templates.statemachine.java.statemachine;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author zhangwen
 * @date 2023/5/26 9:18
 */
public class AuditStateMachine extends AbstractStateMachine {
    @Override
    protected List<StateProcess> init() {
        return Lists.newArrayList(StateProcess.builder().from(State.UN_COMMIT)
                        .to(State.COMMITTED)
                        .event(Event.COMMIT).build(),
                StateProcess.builder().from(State.COMMITTED)
                        .to(State.LEADER_APPROVE)
                        .event(Event.LEADER_AUDIT)
                        .action(new LeaderAuditAction()).build(),
                StateProcess.builder().from(State.COMMITTED)
                        .to(State.REJECTED)
                        .event(Event.LEADER_REJECTED).build(),
                StateProcess.builder().from(State.LEADER_APPROVE)
                        .to(State.FINISH)
                        .event(Event.HR_AUDIT).build(),
                StateProcess.builder().from(State.LEADER_APPROVE)
                        .to(State.FINISH)
                        .event(Event.HR_REJECTED).build()
        );
    }
}
